package com.example.clock.planPage;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.clock.R;
import com.example.clock.basicClass.Plan;
import com.example.clock.basicClass.Task;

import java.util.ArrayList;

public class TaskPlanAdapter extends ArrayAdapter<Task> {

    public TaskPlanAdapter(@NonNull Context context, int resource, @NonNull ArrayList<Task> objects) {

        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Task t= getItem(position);//得到当前项的 Task 实例
        //为每一个子项加载设定的布局
        View view= LayoutInflater.from(getContext()).inflate(R.layout.list_item_task_plan,parent,false);
        //分别获取 image view 和 textview 的实例
        TextView textView1 = view.findViewById(R.id.textView47);
        TextView textView2 = view.findViewById(R.id.textView48);
        TextView textView3 = view.findViewById(R.id.textView49);

        // 设置要显示的图片和文字
        textView1.setText(t.getDate());
        textView2.setText(t.getStartTime()+"-"+t.getEndTime());
        textView3.setText("备注："+t.getTips());

        return view;
    }

}
